<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/thumb/{template}/{filename}','ImageCacheController@getResponse')->name('image');
Route::get('/redis','IndexController@redis');


Route::group(['middleware'=>'config'],function(){
    Route::get('/','IndexController@index');
   // Route::get('/image/{template}/{filename}','ImageCacheController@getResponse')->name('imagecache');
    Route::get('/home','IndexController@home')->name('index');
    Route::get('/get_writing','IndexController@get_writing')->name('get_writing');
    Route::get('/photography','IndexController@photography')->name('photography');
    Route::get('/painting','IndexController@painting')->name('painting');
    Route::get('/site','SiteMapController@create');
    //喜欢
    Route::get('/like','IndexController@like');
    Route::get('/no_like','IndexController@no_like');
    //联系我们
    Route::get('/contact','IndexController@contact')->name('contact');
    //作品详情
    Route::get('/writing_detail','UserController@writing_detail')->name('writing_detail')->middleware('hits');
    //别人的作品主页
    Route::get('/user_detail/{id}','UserController@his_detail')->name('his_detail');
    //得到更多作品
    Route::get('/get_more_writing','UserController@get_more_writing')->name('get_more_writing');
    //删除作品
    Route::get('/writing_del','UserController@writing_del')->name('writing_del');

    Auth::routes();
    Route::post('/upload','Admin\\ImageController@upload')->name('image_upload')->middleware('login');

    Route::group(['prefix'=>'activity'],function(){
        Route::get('/','ActivityController@activity_list')->name('activity_list');
        Route::get('/get_more','ActivityController@get_more')->name('activity.get_more');
        Route::get('/detail','ActivityController@detail')->name('activity.detail');
    });
    //上传图片
    Route::post('/image/upload','ImageController@upload')->name('image_upload');
    //课程
    Route::group(['prefix'=>'course'],function(){
        Route::get('/','CourseController@index')->name('course_list');
        Route::get('/get_more','CourseController@get_more')->name('course.get_more');
        Route::get('/detail','CourseController@detail')->name('course_detail');
        //上传课程
        Route::get('/course_upload','CourseController@course_upload')->name('course_upload');
        Route::post('/course_post','CourseController@course_post')->name('course_post')->middleware('login');
        //删除评论
        Route::get('/comment_del','CourseController@comment_del')->name('comment_del')->middleware('permission:comment_display');
        //课程删除
        Route::get('/course_del','CourseController@course_del')->name('course_del')->middleware('permission:comment_display');
        //课程评论
        Route::post('/comment_post','CourseController@comment_post')->name('comment_post')->middleware('login');

    });
    Route::group(['prefix'=>'user','middleware'=>'login'],function(){
        Route::get('/','UserController@index')->name('user_index');
        Route::get('/upload_writing','UserController@upload_writing')->name('upload_writing');
        Route::get('/get_theme','UserController@get_theme')->name('get_theme');

        //密码修改
        Route::get('/reset_password','UserController@resetPassword')->name('user_reset_password');
        //密码修改提交
        Route::post('/reset_password/store','UserController@resetPasswordPost')->name('user_reset_password_post');
        //作品提交
        Route::post('/writing_store','UserController@writing_store')->name('writing_store');
        //我的作品列表
        Route::get('/writing_list','UserController@writing_list')->name('writing_list');
        //编辑作品
        Route::get('/writing_edit','UserController@writing_edit')->name('writing_edit');
        //
        Route::post('/writing_update/{id}','UserController@writing_update')->name('writing_update');
        //消息通知
        Route::get('/message_list','MessageController@message_list')->name('message_list');
    });
    //作品评论提交
    Route::post('/post_comment','WritingCommentController@post_comment')->name('post_comment')->middleware('login');

    //作品评论列表
    Route::post('/post_index','WritingCommentController@post_index')->name('post_index');
    //屏蔽评论
    Route::post('/display_comment','WritingCommentController@display_comment')->name('display_comment')->middleware('permission:comment_display');

}
);


//更换语言
Route::get('/change_language/{language}', 'IndexController@change');

Route::group(['prefix'=>'admin','middleware'=>'admin.auth'],function(){
    $namespace='Admin\\';
    //admin首页
    Route::get('/',$namespace.'IndexController@index')->name('admin_index');
    Route::get('/main',$namespace.'IndexController@main');
    //退出登陆
    Route::get('/logout',$namespace.'IndexController@logout')->name('admin.logout');
    //得到菜单
    Route::get('/menu',$namespace.'IndexController@menu')->name('admin.menu');
    //图片文件模块
    Route::group(['prefix'=>'image'],function() use($namespace){
        Route::post('/upload',$namespace.'ImageController@upload')->name('admin.image_upload');
        Route::post('/upload1',$namespace.'ImageController@upload1')->name('admin.image_upload1');
    });

    Route::group(['prefix'=>'setting'],function() use($namespace){
        //设置
        Route::post('/setting/post',$namespace.'SettingController@store')->name('admin.setting.post');
        Route::get('/',$namespace.'SettingController@index')->name('admin.setting')->middleware('permission:setting');
        Route::get('/store',$namespace.'SettingController@store')->name('admin.setting_store')->middleware('permission:setting');
    });
    //user模块
    Route::group(['prefix'=>'user'],function() use($namespace){
        //修改密码
        Route::get('/modify_password',$namespace.'UserController@modify_password')->name('admin.modify_password')->middleware('permission:modify_password');
        //修改密码提交
        Route::post('/modify_password/post',$namespace.'UserController@modify_password_post')->name('admin.password_post');
        //编辑用户信息
        Route::get('/{id}/edit',$namespace.'UserController@edit')->name('admin.user_edit')->middleware('permission:user_edit');

        Route::post('/update',$namespace.'UserController@update')->name('admin.user_update')->middleware('permission:user_edit');
        //查看用户信息
        Route::get('/{id}/detail',$namespace.'UserController@detail')->name('admin.user_detail')->middleware('permission:user_detail');
        //增加
        Route::get('/add',$namespace.'UserController@add')->name('admin.user_add')->middleware('permission:user_add');
        Route::post('/store',$namespace.'UserController@store')->name('admin.user_store')->middleware('permission:user_add');
        //屏蔽会员发布的所有作品
        Route::get('/{id}/display',$namespace.'UserController@display')->name('admin.user_display')->middleware('permission:user_display');
        //修改admin个人信息
        Route::get('/user_info',$namespace.'UserController@user_info')->name('admin.user_info');
        //提交修改个人信息
        Route::post('/user_info_post',$namespace.'UserController@user_info_post')->name('admin.user_info_post');
        //用户列表
        Route::get('/index',$namespace.'UserController@index')->name('admin.user_index');
        //设置前台权限
        Route::get('/{id}/set',$namespace.'UserController@user_set')->name('admin.user_set')->middleware('permission:user_set');
        //ajax获取用户数据
        Route::get('/ajax_user_list',$namespace.'UserController@ajax_list')->name('admin.user.ajaxList');

    });

    //角色管理
    Route::group(['prefix'=>'role'],function() use($namespace){
        //列表页
        Route::get('/index',$namespace.'RoleController@index')->name('admin.role_index')->middleware('permission:role_index');
        //ajax获取
        Route::get('/ajax_list',$namespace.'RoleController@ajax_list')->name('admin.role_ajaxList')->middleware('permission:role_index');;
        //增加
        Route::get('/add',$namespace.'RoleController@create')->name('admin.role_add')->middleware('permission:role_add');
        Route::post('/store',$namespace.'RoleController@store')->name('admin.role_store')->middleware('permission:role_add');
        //授予权限
        Route::get('/{id}/permission',$namespace.'RoleController@permission')->name('admin.role_permission')->middleware('permission:role_permission');
        Route::post('/permission/store',$namespace.'RoleController@permissionStore')->name('admin.role_permission_store')->middleware('permission:role_permission');
        //修改
        Route::get('/{id}/edit',$namespace.'RoleController@edit')->name('admin.role_edit')->middleware('permission:role_edit');
        Route::post('/update',$namespace.'RoleController@update')->name('admin.role_update')->middleware('permission:role_edit');
        //删除
        Route::get('/del',$namespace.'RoleController@del')->name('admin.role_del')->middleware('permission:role_del');


    });
    //主题管理
    Route::group(['prefix'=>'theme'],function() use($namespace){
        //主题列表页
        Route::get('/index',$namespace.'ThemeController@index')->name('admin.theme_index')->middleware('permission:theme_index');
        //ajax获取主题列表
        Route::get('/ajax_theme_list',$namespace.'ThemeController@ajax_list')->name('admin.theme_ajaxList')->middleware('permission:theme_index');
        //增加主题
        Route::get('/add',$namespace.'ThemeController@create')->name('admin.theme_add')->middleware('permission:theme_add');
        Route::post('/store',$namespace.'ThemeController@store')->name('admin.theme_store')->middleware('permission:theme_add');
        //修改主题
        Route::get('/{id}/edit',$namespace.'ThemeController@edit')->name('admin.theme_edit')->middleware('permission:theme_add');
        Route::post('/update',$namespace.'ThemeController@update')->name('admin.theme_update')->middleware('permission:theme_add');
        //删除主题
        Route::get('/del',$namespace.'ThemeController@del')->name('admin.theme_del')->middleware('permission:theme_del');
        //批量删除
        Route::get('/delAll',$namespace.'ThemeController@delAll')->name('admin.theme_delAll')->middleware('permission:theme_del');
    });
    //活动管理
    Route::group(['prefix'=>'activity'],function() use($namespace){
        //主题列表页
        Route::get('/index',$namespace.'ActivityController@index')->name('admin.activity_index')->middleware('permission:activity_index');
        //ajax获取主题列表
        Route::get('/ajax_theme_list',$namespace.'ActivityController@ajax_list')->name('admin.activity_ajaxList')->middleware('permission:activity_index');
        //增加主题
        Route::get('/add',$namespace.'ActivityController@create')->name('admin.activity_add')->middleware('permission:activity_add');
        Route::post('/store',$namespace.'ActivityController@store')->name('admin.activity_store')->middleware('permission:activity_add');
        //修改主题
        Route::get('/{id}/edit',$namespace.'ActivityController@edit')->name('admin.activity_edit')->middleware('permission:activity_add');
        Route::post('/update',$namespace.'ActivityController@update')->name('admin.activity_update')->middleware('permission:activity_add');
        //删除主题
        Route::get('/del',$namespace.'ActivityController@del')->name('admin.activity_del')->middleware('permission:activity_del');
        //批量删除
        Route::get('/delAll',$namespace.'ActivityController@delAll')->name('admin.activity_delAll')->middleware('permission:activity_del');
    });
            //摄影与绘画
    Route::group(['prefix'=>'writing'],function() use($namespace){
        //列表页
        Route::get('/index',$namespace.'WritingController@index')->name('admin.writing_index')->middleware('permission:writing_index');
        //ajax获取列表
        Route::get('/ajax_theme_list',$namespace.'WritingController@ajax_list')->name('admin.writing_ajaxList')->middleware('permission:writing_index');
        //ajax获取主题
        Route::get('/get_theme',$namespace.'WritingController@ajax_get_theme')->middleware('permission:writing_index');
        //禁止作品显示
        Route::get('/display',$namespace.'WritingController@display')->middleware('permission:writing_display');
        //允许作品显示
        Route::get('/allow',$namespace.'WritingController@allow')->middleware('permission:writing_display');
      /*  //增加
        Route::get('/add',$namespace.'WritingController@create')->name('admin.writing_add');
        Route::post('/store',$namespace.'WritingController@store')->name('admin.writing_store');*/
        //修改
        Route::get('/{id}/edit',$namespace.'WritingController@edit')->name('admin.writing_edit')->middleware('permission:writing_edit');
        Route::post('/update',$namespace.'WritingController@update')->name('admin.writing_update')->middleware('permission:writing_edit');
        //删除
        Route::get('/del',$namespace.'WritingController@del')->name('admin.writing_del')->middleware('permission:writing_del');
        //批量删除
        Route::get('/delAll',$namespace.'WritingController@delAll')->name('admin.writing_delAll')->middleware('permission:writing_del');

    });

});
//admin 登陆
Route::get('admin/login','Admin\LoginController@showLoginForm');
//登录表单提交
Route::post('admin/loginPost','Admin\LoginController@Login')->name('admin.login');

Route::get('/error','Admin\IndexController@error')->name('admin.error');